//
//  TargetIconPicker.swift
//  Accounting
//
//  Created by Qingke on 16/5/9.
//  Copyright © 2016年 Qingke. All rights reserved.
//

import UIKit

protocol IconPickDelegate: class {
    func iconpickDelegateViewController(viewcontroller: TargetIconPicker,icon: String)
}

class TargetIconPicker: UITableViewController {

    
    let iconDic = ["breakfast","lunch","dinner","book","bus"]
    var iconDelegate: IconPickDelegate?
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return iconDic.count
    }


    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
        let icon = iconDic[indexPath.row]
        
        cell.textLabel?.text = icon
        cell.imageView?.image = UIImage(named: icon)
        
        

        return cell
    }

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        let icon = iconDic[indexPath.row]
        iconDelegate?.iconpickDelegateViewController(self, icon: icon)
        
        navigationController?.popViewControllerAnimated(true)
    }

   
}
